// Author: DormoTheNord
// tradeRoute.sqf
// Created: 2/19/2011
// Updated: 2/21/2011
// This script handles trade routes
// Parameters: 
// [unit, startingMarkerNumber] 

#define MAIN_TRADE "foo_"
//_foo = "";
// unit to follow the trade route
_unit = _this select 0;
_markerNum = _this select 1; 

_unitGroup = group _unit;

_wpIndex = 1;

_markerName = (MAIN_TRADE + str(_markerNum));

while { ((getMarkerPos _markerName) select 0) != 0 &&
		((getMarkerPos _markerName) select 1) != 0; } do
{
	//_foo = _foo + str(_markerNum);
	_unitGroup addWaypoint [getMarkerPos _markerName, 0];
	_wpIndex = _wpIndex + 1;
	_markerNum = _markerNum + 1;
	_markerName = (MAIN_TRADE + str(_markerNum));
};

for [ {_markerNum = 0;}, 
	  {_markerNum < (_this select 1);}, 
	  {_markerNum = _markerNum + 1;}] do
{
	//_foo = _foo + str(_markerNum);
	_markerName = (MAIN_TRADE + str(_markerNum));
	_unitGroup addWaypoint [getMarkerPos _markerName, 0];
	_wpIndex = _wpIndex + 1;
};

//_cycle = _unitGroup addWaypoint [[1,1,0], 0];
_cycle = _unitGroup addWaypoint [getMarkerPos (MAIN_TRADE + str((_this select 1))),0];
_cycle setWaypointType "CYCLE";
//deleteWaypoint [_unitGroup,0];


